import * as koa from 'koa';
import * as serve from 'koa-static';
import * as path from 'path';
import * as bodyParser from 'koa-bodyParser';
import router from './router';

export const app = new koa();
app.use(async (ctx, next) => {
  ctx.body = {};
  ctx.type = 'text/html;charset=utf-8';
  await next();
});

app.use(bodyParser());
// app.use(cors);

app.use(router.routes()).use(router.allowedMethods());
app.use(serve(path.join(__dirname, '../')));

app.listen(process.env.PORT || 3001);
